package util;

import java.sql.*;

public class DBConn {
	static {
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

		} catch (Exception ex) {
			ex.printStackTrace();
		}

	}

	public static Connection getConn() {
		try {
			Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databasename=jpwsdg","sa", "sa");

			return conn;
		} catch (Exception ex) {
			ex.printStackTrace();
			return null;
		}
	}

	public static void close(Connection conn, Statement st, ResultSet rs) {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException ex) {
			}
		}
		if (st != null) {
			try {
				st.close();
			} catch (Exception ex) {
			}
		}
		if (conn != null) {
			try {
				conn.close();
			} catch (Exception ex) {
			}
		}
	}
	public static void closeCon(Connection con) {
		try {
			if (con != null || !con.isClosed())
				con.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
